package com.mybatisflex.test.dictionary;

import com.mybatisflex.annotation.DictionarySetListener;

import java.util.HashMap;
import java.util.Map;

/**
 * 字典监听
 *
 * @author zhang
 */
public class StudentSetListener implements DictionarySetListener {

    private static final Map<String, Map<String, String>> DICT_MAP = new HashMap<>();

    static {
        DICT_MAP.put("ST001", new HashMap<String, String>() {{
            put("0", "女");
            put("1", "男");
            put("2", "未知");
        }});
        DICT_MAP.put("ST002", new HashMap<String, String>() {{
            put("01", "小班");
            put("02", "中班");
            put("03", "大班");
        }});
    }

    @Override
    public String getDictName(String mainCd, Object subCd) {
        if (DICT_MAP.containsKey(mainCd)) {
            return DICT_MAP.get(mainCd).get(String.valueOf(subCd));
        }
        return null;
    }
}
